
#include <iostream>

#include <array.hpp>

#include <Octree.h>

#include "test.h"

const int POINT_MAX_COUNT = 128;
const Vec3 BOX_MIN = {-1.0f, -1.0f, -1.0f};
const Vec3 BOX_MAX = {1.0f, 1.0f, 1.0f};
const Vec3 BOX_ORIGIN = {0.0f, 0.0f, 0.0f};
const Vec3 BOX_RADIUS = {1.f, 1.f, 1.f};

const Vec3 SEARCH_MIN = {-.5f, -.5f, -.5f};
const Vec3 SEARCH_MAX = {.5f, .5f, .5f};

// 生成 [-1,1] 之间的随机数
float rand11() {
    return -1.f + (2.f * rand()) * (1.f / RAND_MAX);
}

int main() {
    RunTimerLogger("main");
    auto points = TingSTL::array<Vec3>(POINT_MAX_COUNT);

    for (int i = 0; i < POINT_MAX_COUNT; ++i)
        points.emplace_back(rand11(), rand11(), rand11());

    auto oct = Octree::buildOctree(BOX_ORIGIN, BOX_RADIUS, points);
    auto boxPoints = oct.getPointsInsideBox(SEARCH_MIN, SEARCH_MAX);

    std::cout << "search point count: " << boxPoints.size();
}